--[[/**
 * 费内特 技能3
 * 自身附近2码范围内每存在一名敌人 增加属性
-- */]]

---@class BuffEffect365100 : BaseBuffEffect
BuffEffect365100 = ClientFight.CreateClass("BuffEffect365100", ClientFight.BaseBuffEffect)
local t = BuffEffect365100

---@param fight Fight
---@param buff FighterBuff
function t:action(fight, buff, ...)
    local fighter = buff.target;
    local fightTeam = fight.teams[3 - fighter.teamIndex];
    local effectValues = buff.buffBean.f_BuffEffectValue;
    local peopleAmount = 0;

    for k, f in pairs(fightTeam.fighters) do
        if (f:isDie()) then
            goto continue;
        end
        if (f:isSummons() and not f.isRealSummons()) then
            goto continue;
        end
        if (DistanceUtil.countDistance(fighter.position, f.position) <= MathUtil.toRatio(effectValues[1])) then
            peopleAmount = peopleAmount + 1;
        end
        ::continue::
    end
    local logPeopleAmount = peopleAmount;
    buff.attributes.attributes = {};
    buff.attributes.attributes[effectValues[2]] = effectValues[3] * peopleAmount;
    buff.attributes.attributes[effectValues[4]] = effectValues[5] * peopleAmount;
    SkillRoleMgr.savePathFile(string.format("[%s][EFFECT]Fighter %s buff%s 周围存在%s人",
            fight.frame, fighter.fighterId, buff.modelId, logPeopleAmount
    ));
    ClientFight.BaseBuffEffect.action(self, fight, buff, ...);
    return IBuffEffect.SUCCESS_ATTRI_HAS_CHANGE;
end

t.New()